package com.hong.collections.concurrent;


import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentSkipListMap;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @Author csh
 * @Description
 * @Date 2018/8/19 17:42
 */
public class ConcurrentSkipListMapVsConcurrentHashMap {

    static class Entry{
        int count;
        long ms;

        public Entry(int count, long ms) {
            this.count = count;
            this.ms = ms;
        }

        @Override
        public String toString() {
            return "Count:"+count+",ms:"+ms;
        }
    }

    private final static Map<Class<?>,List<Entry>> summary = new HashMap<Class<?>,List<Entry>>(){
        {
        }
    };

    public static void main(String[] args) throws InterruptedException {
        pressureTest(new ConcurrentHashMap<>(),10);
        pressureTest(new ConcurrentSkipListMap<>(),10);
    }

    private static void pressureTest(final Map<String,Integer> map,int threshold)throws InterruptedException{
        System.out.println("Sart pressure testing the map["+map.getClass()+"] use the threshold ["+threshold +" ]");
        long totalTime = 0L;
        final int MAX_THRESHOLD = 500000;
        for (int i = 0;i<5;i++){
            final AtomicInteger counter = new AtomicInteger(0);
            map.clear();
        }

    }
}
